package com.study.service.communication;

import com.study.service.communication.hystrix.AuthorityFeignClientFallbackFactory;
import com.study.vo.JwtToken;
import com.study.vo.UsernameAndPassword;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


@FeignClient(contextId = "AuthorityFeignClient",value = "ecommerce-authority-center",
        //fallback = AuthorityFeignClientFallback.class
        //openfeign 集成 hystrix
        fallbackFactory = AuthorityFeignClientFallbackFactory.class
)
@Component
public interface AuthorityFeignClient {

    //通过 OpenFeign 访问 Authority 获取Token
    @RequestMapping(value = "ecommerce-authority-center/authority/getToken",
            method = RequestMethod.POST,
            consumes = "application/json",
            produces = "application/json")
    JwtToken getTokenByFeign(@RequestBody UsernameAndPassword usernameAndPassword);


}
